package org.example.config;

import org.example.service.PaymentService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class PaymentServicePostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof PaymentService) {
            System.out.println("Before initialization: Enhancing PaymentService for security and logging.");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof PaymentService) {
            System.out.println("PaymentServicePostProcessor: AfterInitialization - " + beanName);
        }
        return bean;
    }
}